home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Convert String to Int?
- Date: Tue, 05 Mar 96 17:29:52 GMT
- Organization: none
- Message-ID: <826046992snz@genesis.demon.co.uk>
- References: <4hf3sk$k57@hustle.rahul.net> <4hfs0l$k2i@newsbf02.news.aol.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4hfs0l$k2i@newsbf02.news.aol.com> razine@aol.com "Razine" writes:
-
- >I would suggest using atoi.
- >
- >example
- >
- >#include <stdio.h>
- >#include <stdlib.h>
- >
- >int main()
- >{
- >
- > char number[3]='999';
-
- This should be:
-
- char number[4]="999";
-
- or equivalently:
-
- char number[]="999";
-
- atoi() requires that you pass it a string which means that the sequence
- of characters must be terminated by the null character.
-
- > int result;
- >
- > result=atoi(number);
- > printf("Result == %d\n",result);
- > return 0;
- > }
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-